//
//  UIBarButtonItem+Extensions.swift
//  WB_Swift3.0
//
//  Created by wangrui on 2017/3/13.
//  Copyright © 2017年 wangrui. All rights reserved.
//

import UIKit

extension UIBarButtonItem
{
    
    ///  自定义UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: 标题
    ///   - fontSize: 标题大小：默认16
    ///   - target: 监听者
    ///   - action: 点击事件
    ///   - isBack: 是否是返回按钮：默认不是
    convenience init(title:String, fontSize:CGFloat=16, target:Any?, action:Selector, isBack:Bool=false)
    {
        let button:UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
        button.addTarget(target, action: action, for: .touchUpInside)
        if isBack == true
        {
            let imgName = "navigationbar_back_withtext"
            button.setImage(UIImage(named:imgName), for: .normal)
            button.setImage(UIImage(named:imgName + "_highlighted"), for: .highlighted)
            button.sizeToFit()
        }
        self.init(customView:button)
    }
}
